<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="./index.css">
  <link rel="stylesheet" href="./fonts/iconfont.css">
</head>

<body>
  <div class="navigation">
    <div class="menuToggle"></div>
    <ul>
      <li class="list active">
        <a href="#" style="--clr:#f44336;">
          <span class="icon">
            <i class="iconfont icon-home"></i>
          </span>
          <span class="text">Home</span>
        </a>
      </li>
      <li class="list">
        <a href="#" style="--clr:#ffa117;">
          <span class="icon">
            <i class="iconfont icon-user"></i>
          </span>
          <span class="text">About</span>
        </a>
      </li>
      <li class="list">
        <a href="#" style="--clr:#0fc70f;">
          <span class="icon">
            <i class="iconfont icon-chat"></i>
          </span>
          <span class="text">Messages</span>
        </a>
      </li>
      <li class="list">
        <a href="#" style="--clr:#2196f3;">
          <span class="icon">
            <i class="iconfont icon-xiangji1"></i>
          </span>
          <span class="text">Photos</span>
        </a>
      </li>
      <li class="list">
        <a href="#" style="--clr:#b145e9;">
          <span class="icon">
            <i class="iconfont icon-setting"></i>
          </span>
          <span class="text">Settings</span>
        </a>
      </li>
    </ul>
  </div>
  
  <script>
    let navigation = document.querySelector('.navigation')
    let menuToggle = document.querySelector('.menuToggle')

    menuToggle.addEventListener('click', function () {
      navigation.classList.toggle('active')
    })

    let list = document.querySelectorAll('.list')
    function activeLink() {
        list.forEach(item=>{
          item.classList.remove('active')
          this.classList.add('active')
        })
    }

    list.forEach(item => {
      item.addEventListener('click',activeLink)
    })

  </script>
</body>

</html>